package com.yxb.system.service.impl;
import com.yxb.common.utils.DateUtils;
import com.yxb.system.mapper.NotificationMapper;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yxb.system.domain.Notification;
import com.yxb.system.service.INotificationService;

import static com.yxb.common.utils.SecurityUtils.getLoginUser;

/**
 * 系统消息通知Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-03-04
 */
@Service
public class NotificationServiceImpl implements INotificationService 
{
    @Autowired
    private NotificationMapper notificationMapper;

    /**
     * 查询系统消息通知
     * 
     * @param msgId 系统消息通知主键
     * @return 系统消息通知
     */
    @Override
    public Notification selectNotificationByMsgId(Long msgId)
    {
        return notificationMapper.selectNotificationByMsgId(msgId);
    }

    /**
     * 查询系统消息通知列表
     * 
     * @param notification 系统消息通知
     * @return 系统消息通知
     */
    @Override
    public List<Notification> selectNotificationList(Notification notification)
    {
        return notificationMapper.selectNotificationList(notification);
    }

    /**
     * 新增系统消息通知
     * 
     * @param notification 系统消息通知
     * @return 结果
     */
    @Override
    public int insertNotification(Notification notification)
    {
        notification.setSenderId(getLoginUser().getUserId());
        notification.setUserId(getLoginUser().getUserId());
        notification.setSendTime(DateUtils.getNowDate());
        return notificationMapper.insertNotification(notification);
    }

    /**
     * 修改系统消息通知
     * 
     * @param notification 系统消息通知
     * @return 结果
     */
    @Override
    public int updateNotification(Notification notification)
    {
        return notificationMapper.updateNotification(notification);
    }

    /**
     * 批量删除系统消息通知
     * 
     * @param msgIds 需要删除的系统消息通知主键
     * @return 结果
     */
    @Override
    public int deleteNotificationByMsgIds(Long[] msgIds)
    {
        return notificationMapper.deleteNotificationByMsgIds(msgIds);
    }

    /**
     * 删除系统消息通知信息
     * 
     * @param msgId 系统消息通知主键
     * @return 结果
     */
    @Override
    public int deleteNotificationByMsgId(Long msgId)
    {
        return notificationMapper.deleteNotificationByMsgId(msgId);
    }

    @Override
    public List<Notification> getAll() {
        List<Notification> list = notificationMapper.getAll();
        System.out.println(list);
        return notificationMapper.getAll();
    }
}
